# class Gamer:
#     def __init__(self, gamer, gjl1=20, heart1=100):
#         self.gamer = gamer  # 玩家名称
#         self.gjl = gjl1      # 攻击力
#         self.heart = heart1  # 血量
#
#     def gongji(self, enemy):  # 修改参数名为enemy更清晰
#         print(f"{self.gamer}攻击了{enemy.df}造成了{self.gjl}伤害")  # 使用f-string更直观
#         enemy.health(self.gjl)  # 调用敌人的health方法
#
#     def health(self, damage):  # 参数名改为damage更明确
#         self.heart -= damage
#         print(f"{self.gamer}剩余血量：{self.heart}")  # 显示谁的血量
#
# class Df:
#     def __init__(self, df, gjl2=20, heart2=100):
#         self.df = df      # 敌人名称
#         self.gjl = gjl2   # 攻击力
#         self.heart = heart2  # 血量
#
#     def gongji(self, player):  # 参数名改为player更清晰
#         print(f"{self.df}攻击了{player.gamer}造成了{self.gjl}伤害")
#         player.health(self.gjl)  # 调用玩家的health方法
#
#     def health(self, damage):
#         self.heart -= damage
#         print(f"{self.df}剩余血量：{self.heart}")
#
# # 创建实例
# player = Gamer("玩家")  # 变量名改为player更清晰
# enemy = Df("敌人")     # 变量名改为enemy更清晰
#
# # 玩家攻击敌人
# player.gongji(enemy)


# 1. 添加
class Controller:
    def __init__(self):
        self.list_movie=[
            {"name": "八角笼中", "index": 690761},
            {"name": "封神第一部", "index": 532622}
        ]
    def app_movie(self,dict_movie):
        self.list_movie.append(dict_movie)
# 2. 定位
# 2.1 读取
    def list_movies(self):
        for item in self.list_movie:
            print("电影名:%s,热搜指数:%s"%(item["name"],item["index"]))
# 2.2 修改
    def update(self):
        for item in self.list_movie:
           item["index"] += 10
# 3. 删除
    def remove_1(self):
        for i in range(len(self.list_movie)):
            if self.list_movie[i]["name"] == "八角笼中":
                del self.list_movie[i]
            break

a = {"name": "消失的她", "index": 446700}
controller = Controller()
controller.app_movie(a)
controller.list_movies()
controller.update()
controller.list_movies()
controller.remove_1()
controller.list_movies()